package com.example.medicine.controller;


import com.example.medicine.Bean.Team;
import com.example.medicine.Mapper.TeamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/team")
public class TeamController {
    @Autowired
    private TeamMapper teamMapper;

    /**
     * 接收teamList请求，返回数据库的Team表内的所有内容，格式为json
     * @return
     */
    @GetMapping("/")
    public List<Team> getTeamList(){
        return teamMapper.getAll();
    }

    /**
     * 接收insertTeam请求，向Team中插入内容
     */
    @PostMapping("/")
    public void insertTeam(@RequestBody Team team){
        teamMapper.insert(team);
    }

    /**
     * 接收updateTeam请求，根据ID值更新Team内容
     */
    @PutMapping("/")
    public void updateTeam(@RequestBody Team team){
        teamMapper.update(team);
    }

    @DeleteMapping("/{id}")
    public void deleteTeam(@PathVariable String id){
        teamMapper.deleteById(id);
    }
}
